Hi guys! I have small problem with Master Page. I have created Web Template and Master Page. When I create new site collection and I try access to it (http://win2008r2/sites/Test), it throws me error that: "The webpage cannot be found".
However, when I check MasterPage gallery: http://win2008r2/sites/Test/_catalogs/masterpage/Forms/AllItems.aspx
I can find my Demo.master . When I check Site Collection Features, I can see that my Master Page feature is
active.
I have set Web Template scope to farm and I have set Master Page scope to site.
I checked the logs and this was only thing what I found: Failure when fetching document. 0x80070002
I try to solve problem using google and I tried different guides but no I cannot get it work.
Can anyone please help me?
Here is Element.xml:
<Module Name="MyMasterPage" List="116" Url="_catalogs/masterpage"> <File Path="MyMasterPage\Demo.master" Url="Demo.master" Type="GhostableInLibrary"> </File> </Module>
Here is event receiver:
public override void FeatureActivated(SPFeatureReceiverProperties properties) { SPSecurity.RunWithElevatedPrivileges(delegate { using (SPWeb _web = ((SPSite)properties.Feature.Parent).RootWeb) { Uri _siteMaster = new Uri(string.Format("{0}/_catalogs/masterpage/Demo.master", _web.Url)); _web.MasterUrl = _siteMaster.AbsolutePath; _web.CustomMasterUrl = _siteMaster.AbsolutePath; _web.Update(); } }); } public override void FeatureDeactivating(SPFeatureReceiverProperties properties) { SPSite curSite = (SPSite)properties.Feature.Parent; SPWeb curWeb = curSite.RootWeb; Uri masterUri = new Uri(curWeb.Url + "/_catalogs/masterpage/v4.master"); curWeb.MasterUrl = masterUri.AbsolutePath; curWeb.CustomMasterUrl = masterUri.AbsolutePath; curWeb.Update(); }
- Edited by Lindsey24 Wednesday, January 08, 2014 7:54 AM Added error code